class TagModel {
  final int id;
  final String title;
  final int status;
  final int weight;
  final int deleted;
  final String? createUser;
  final String? updateUser;
  final List<int> createTime;
  final List<int> updateTime;
  final int type;

  TagModel({
    required this.id,
    required this.title,
    required this.status,
    required this.weight,
    required this.deleted,
    this.createUser,
    this.updateUser,
    required this.createTime,
    required this.updateTime,
    required this.type,
  });

  factory TagModel.fromJson(Map<String, dynamic> json) {
    return TagModel(
      id: json['id'],
      title: json['title'],
      status: json['status'],
      weight: json['weight'],
      deleted: json['deleted'],
      createUser: json['createUser'],
      updateUser: json['updateUser'],
      createTime: List<int>.from(json['createTime']),
      updateTime: List<int>.from(json['updateTime']),
      type: json['type'],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'title': title,
      'status': status,
      'weight': weight,
      'deleted': deleted,
      'createUser': createUser,
      'updateUser': updateUser,
      'createTime': createTime,
      'updateTime': updateTime,
      'type': type,
    };
  }

  // 获取格式化的显示名称（添加#前缀）
  String get displayName => '#$title';

  // 判断是否为激活状态
  bool get isActive => status == 1 && deleted == 1;
}
